/**
 * 系统主页
 */
orange.homepage = {
	data: [
       {text: '门诊总数', name: '河北省', color:'#c23531',
	       	data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]},
	   {text: '处方总数', name: '河北省', color:'#61a0a8',
	       	data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]},
       {text: '费用总数', name: '河北省', color:'#dd8668',
	       	data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]},
	   {text: '医师总数', name: '河北省', color:'#91c7ae',
		    data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]},
	   {text: '辅助开方总数', name: '河北省', color:'#bda29a',
		    data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]},
	   {text: '远程诊疗总数', name: '河北省', color:'#c4ccd3',
			data: [{name: '河北省', value: 1500000}, {name: '其他省', value: 30000000}]}
    ],
	init: function() {	//	模块初始化
		this.getData();
		this.loadChinaMap();
		this.loadPies();
	},
	getData : function(){
		$.ajax({
		     url:'homepage/getProvincePercent',//+encodeURI(encodeURI("北京市"))+'/'+encodeURI(encodeURI("北京市"))+'/'+encodeURI(encodeURI("东城区")),
		     type: 'post',
		     data:{
		    	 province:'浙江省'
				},
		     success: function(data) {
		     }
		 });
	},
	loadChinaMap: function() {	//	渲染中国地图
		var chart = echarts.init(document.getElementById('homepage_chinaMap'));
		chart.setOption({
			tooltip: {
		        trigger: 'item',
		        formatter: '{b}'
		    },
		    series: [
		        {
		            name: '中国',
		            type: 'map',
		            mapType: 'china',
		            selectedMode : 'single',
		            itemStyle: {
		                emphasis:{label:{show:true}}
		            },
		            data: [
		                {name:'河北',selected:true}
		            ]
		        }
		    ]
		});
	},
	loadPies: function() {
		var i = 0, ids = ['pie_1','pie_2','pie_3','pie_4','pie_5','pie_6'];
		for(i; i<ids.length; i++) {
			this.loadPie(ids[i], this.data[i]);
		}
	},
	loadPie: function(id, data) {
		var pie = echarts.init(document.getElementById(id));
		var precent = data.data[0].value/data.data[1].value;
		pie.setOption({
			title: {
		        text: data.text,
		        subtext: '占比: ' + precent + '%',
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    color:[data.color, '#314656'],
		    series: [
		        {
		            name: data.name,
		            type: 'pie',
		            radius : '55%',
		            center: ['30%', '60%'],
		            data: [{name: '河北省', value: '1500000'}, {name: '其他省', value: '30000000'}],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		});
	}
};

orange.homepage.init();

